//引入封装好的接口
import {getMenuList} from '@/request/api'
//封装一个state接口
interface menuSate {
    menulist: Array<object>
}

//封装state
const state = {
    menulist: []
}
//getters
const getters = {
    getMenu(state: menuSate) {
        return state.menulist
    }
}
//mutations
const mutations = {
    REQ_MENULIST(state:menuSate,payload:any){
        state.menulist = payload
    }
}

//行动
const actions = {
    //封装一个行动
    getMenuAction(context:any){
        getMenuList()
        .then((res:any)=>{
            console.log(res,'列表');
            if(res.code==200){
                context.commit('REQ_MENULIST',res.list)
            }
        })
    }
}


//导出封装好的属性
export default {
    state,
    getters,
    mutations,
    actions,
    //开一个命名空间
    namespaced: true
}